package com.fzh.web.yibai.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzh.web.yibai.app.entity.Banner;
import com.fzh.web.yibai.app.mapper.BannerMapper;
import com.fzh.web.yibai.app.service.BannerService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fang
 * @since 2021-04-19
 */
@Service
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService {

    @Override
    public Banner findBanner(Integer webSiteId, Integer position) {
     QueryWrapper<Banner> wrapper = new QueryWrapper<>();
        wrapper.eq("site_id",webSiteId);
        wrapper.eq("position",position);
        wrapper.eq("status","T");
        wrapper.orderByAsc("create_time");
        wrapper.last("limit 1");
        return baseMapper.selectOne(wrapper);
    }
}
